home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / ProgressMonitor.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  3.7 KB  |  164 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4.  
  5. public class ProgressMonitor {
  6.    private ProgressMonitor root;
  7.    private JDialog dialog;
  8.    private JOptionPane pane;
  9.    private JProgressBar myBar;
  10.    private JLabel noteLabel;
  11.    private Component parentComponent;
  12.    private String note;
  13.    private Object[] cancelOption;
  14.    private Object message;
  15.    // $FF: renamed from: T0 long
  16.    private long field_0;
  17.    private int millisToDecideToPopup;
  18.    private int millisToPopup;
  19.    private int min;
  20.    private int max;
  21.    // $FF: renamed from: v int
  22.    private int field_1;
  23.    private int lastDisp;
  24.    private int reportDelta;
  25.  
  26.    public ProgressMonitor(Component var1, Object var2, String var3, int var4, int var5) {
  27.       this(var1, var2, var3, var4, var5, (ProgressMonitor)null);
  28.    }
  29.  
  30.    private ProgressMonitor(Component var1, Object var2, String var3, int var4, int var5, ProgressMonitor var6) {
  31.       this.cancelOption = null;
  32.       this.millisToDecideToPopup = 500;
  33.       this.millisToPopup = 2000;
  34.       this.min = var4;
  35.       this.max = var5;
  36.       this.parentComponent = var1;
  37.       this.cancelOption = new Object[1];
  38.       this.cancelOption[0] = UIManager.getString("OptionPane.cancelButtonText");
  39.       this.reportDelta = (var5 - var4) / 100;
  40.       if (this.reportDelta < 1) {
  41.          this.reportDelta = 1;
  42.       }
  43.  
  44.       this.field_1 = var4;
  45.       this.message = var2;
  46.       this.note = var3;
  47.       if (var6 != null) {
  48.          this.root = var6.root != null ? var6.root : var6;
  49.          this.field_0 = this.root.field_0;
  50.          this.dialog = this.root.dialog;
  51.       } else {
  52.          this.field_0 = System.currentTimeMillis();
  53.       }
  54.  
  55.    }
  56.  
  57.    // $FF: synthetic method
  58.    static Object[] access$0(ProgressMonitor var0) {
  59.       return var0.cancelOption;
  60.    }
  61.  
  62.    public void close() {
  63.       if (this.dialog != null) {
  64.          this.dialog.setVisible(false);
  65.          this.dialog.dispose();
  66.          this.dialog = null;
  67.          this.pane = null;
  68.          this.myBar = null;
  69.       }
  70.  
  71.    }
  72.  
  73.    public int getMaximum() {
  74.       return this.max;
  75.    }
  76.  
  77.    public int getMillisToDecideToPopup() {
  78.       return this.millisToDecideToPopup;
  79.    }
  80.  
  81.    public int getMillisToPopup() {
  82.       return this.millisToPopup;
  83.    }
  84.  
  85.    public int getMinimum() {
  86.       return this.min;
  87.    }
  88.  
  89.    public String getNote() {
  90.       return this.note;
  91.    }
  92.  
  93.    public boolean isCanceled() {
  94.       if (this.pane == null) {
  95.          return false;
  96.       } else {
  97.          Object var1 = this.pane.getValue();
  98.          return var1 != null && this.cancelOption.length == 1 && var1.equals(this.cancelOption[0]);
  99.       }
  100.    }
  101.  
  102.    public void setMaximum(int var1) {
  103.       this.max = var1;
  104.    }
  105.  
  106.    public void setMillisToDecideToPopup(int var1) {
  107.       this.millisToDecideToPopup = var1;
  108.    }
  109.  
  110.    public void setMillisToPopup(int var1) {
  111.       this.millisToPopup = var1;
  112.    }
  113.  
  114.    public void setMinimum(int var1) {
  115.       this.min = var1;
  116.    }
  117.  
  118.    public void setNote(String var1) {
  119.       this.note = var1;
  120.       if (this.noteLabel != null) {
  121.          this.noteLabel.setText(var1);
  122.       }
  123.  
  124.    }
  125.  
  126.    public void setProgress(int var1) {
  127.       this.field_1 = var1;
  128.       if (var1 >= this.max) {
  129.          this.close();
  130.       } else if (var1 >= this.lastDisp + this.reportDelta) {
  131.          this.lastDisp = var1;
  132.          if (this.myBar != null) {
  133.             this.myBar.setValue(var1);
  134.          } else {
  135.             long var2 = System.currentTimeMillis();
  136.             long var4 = (long)((int)(var2 - this.field_0));
  137.             if (var4 >= (long)this.millisToDecideToPopup) {
  138.                int var6;
  139.                if (var1 > this.min) {
  140.                   var6 = (int)(var4 * (long)(this.max - this.min) / (long)(var1 - this.min));
  141.                } else {
  142.                   var6 = this.millisToPopup;
  143.                }
  144.  
  145.                if (var6 >= this.millisToPopup) {
  146.                   this.myBar = new JProgressBar();
  147.                   this.myBar.setMinimum(this.min);
  148.                   this.myBar.setMaximum(this.max);
  149.                   this.myBar.setValue(var1);
  150.                   if (this.note != null) {
  151.                      this.noteLabel = new JLabel(this.note);
  152.                   }
  153.  
  154.                   this.pane = new ProgressOptionPane(this, new Object[]{this.message, this.noteLabel, this.myBar});
  155.                   this.dialog = this.pane.createDialog(this.parentComponent, "Progress...");
  156.                   this.dialog.show();
  157.                }
  158.             }
  159.          }
  160.       }
  161.  
  162.    }
  163. }
  164.